package dwz.cms.article.util.ftp;

import java.util.Vector;


/**
 * Created by Eclipse
 * 
 * @author : Yating
 * @version:2017年5月9日 上午9:04:01 类说明
 */
public class UpLoadThread extends Thread {
	private Vector<MyFTPFile> files;
	private String host;
	private int port;
	private String userName;
	private String password;
	private String initPath;
	private FtpError ftperror;
	private String goalPath;

	public UpLoadThread() {
		super();
	}

	public FtpError getFtperror() {
		return ftperror;
	}

	public void setFtperror(FtpError ftperror) {
		this.ftperror = ftperror;
	}

	public Vector<MyFTPFile> getFiles() {
		return files;
	}

	public void setFiles(Vector<MyFTPFile> files) {
		this.files = files;
	}

	public String getHost() {
		return host;
	}

	public void setHost(String host) {
		this.host = host;
	}

	public int getPort() {
		return port;
	}

	public void setPort(int port) {
		this.port = port;
	}

	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getInitPath() {
		return initPath;
	}

	public void setInitPath(String initPath) {
		this.initPath = initPath;
	}

	public UpLoadThread(Vector<MyFTPFile> files, String host, int port, String userName, String password,
			String initPath) {
		super();
		this.files = files;
		this.host = host;
		this.port = port;
		this.userName = userName;
		this.password = password;
		this.initPath = initPath;
		this.goalPath = goalPath;
	}

	@Override
	public void run() {
		FTPUtils ftp = new FTPUtils();
		ftp.setInitPath(initPath);
		String mess = "";
		if (ftperror != null) {
			try {
				ftp.getConnection(host, port, userName, password);
				mess = ftp.autoUpdate(files);
				ftp.closeConnect();
				ftperror.getHashtable().put(host, mess);
			} catch (Exception e) {
				ftperror.getHashtable().put(host, mess);
				e.printStackTrace();
			}
		}
	}

	public String getGoalPath() {
		return goalPath;
	}

	public void setGoalPath(String goalPath) {
		this.goalPath = goalPath;
	}

}
